<template>
	<view class="wrap">
		<u-gap height="20" bg-color="#f5f5f5"></u-gap>
		<u-cell-group :border="false">
			<u-cell-item title="通用" @click="navTo('')" :arrow="true"></u-cell-item>
			<u-gap height="20" bg-color="#f5f5f5"></u-gap>
			<u-cell-item title="版本更新" @click="navTo('')" :arrow="true"></u-cell-item>
			<u-cell-item title="隐私政策" @click="navTo('')" :arrow="true"></u-cell-item>
			<u-cell-item title="用户协议" @click="navTo('')" :arrow="true"></u-cell-item>
		</u-cell-group>
		<u-gap height="20" bg-color="#f5f5f5"></u-gap>
		<view><u-button :loading="isLogout" class="sign-out" @click="handleLogout" :hair-line="false">退出登录</u-button></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isLogout: false
		}
	},
	methods: {
		/* 退出登录回调 */
		async handleLogout() {
			// 禁止多次点击
			this.isLogout = true
			// 给服务器发请求退出
			try {
				await this.$axios.post('/logout')
				this.isLogout = false
				// 清空本地用户数据
				uni.removeStorage({ key: 'admin' })
				uni.removeStorage({ key: 'userInfo' })
				// 跳转到登录界面
				this.$showToast.none('已退出登录')
				uni.reLaunch({ url: '/pages/login/loginPage' })
			} catch (e) {
				this.isLogout = false
			}
		}
	}
}
</script>

<style lang="scss">
page {
	background-color: #f5f5f5;
}

/deep/ .u-cell-title {
	padding: 25rpx 30rpx;
	font-size: 30rpx;
}
</style>
